package BankingTaskManagement;

public class BankAccount {

    private double balance;
    private int depositsCount;
    private int withdrawalsCount;
    private double annualInterestRate;
    private double monthlyServiceCharges;

    public BankAccount(double balance, double annualInterestRate) {
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
        this.depositsCount = 0;
        this.withdrawalsCount = 0;
        this.monthlyServiceCharges = 0;
    }

    public void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
            depositsCount++;
            System.out.println("Deposit successful. New balance: RMB " + balance);
        } else {
            System.out.println("Invalid deposit amount.");
        }
    }

    public boolean withdraw(double amount) {
        if (balance >= amount && balance - amount >= 25) {
            balance -= amount;
            withdrawalsCount++;
            System.out.println("Withdrawal successful. New balance: RMB " + balance);
            return true;
        } else {
            System.out.println("Invalid withdrawal amount or insufficient balance.");
            return false;
        }
    }

    public void calcInterest() {
        double monthlyInterestRate = annualInterestRate / 12;
        balance += balance * monthlyInterestRate;
        System.out.println("Interest calculated. New balance: RMB " + balance);
    }

    public void monthlyProcess() {
        balance -= monthlyServiceCharges;
        calcInterest();
        depositsCount = 0;
        withdrawalsCount = 0;
        monthlyServiceCharges = 0;
        System.out.println("Monthly processing completed.");
    }

    public void displayAccountDetails() {
        System.out.println("Balance: RMB " + balance);
        System.out.println("Deposits this month: " + depositsCount);
        System.out.println("Withdrawals this month: " + withdrawalsCount);
    }

    public double getBalance() {
        return balance;
    }
}